Ext.onReady(function() {
	Ext.apply(Ext.view.View.EventMap, {
		change: 'Change'
	});
	Ext.override(Ext.view.View, {
		onBeforeItemChange: Ext.emptyFn,
		onItemChange: Ext.emptyFn,
		onBeforeItemundefined: Ext.emptyFn
	});
	
	Ext.data.validations.greaterThanZeroMessage = "El valor de este campo debe ser mayor que cero";
	Ext.data.validations.greaterThanZero = function(config, value){
		try{
			value = parseFloat(value);
			return value > 0;
		}catch(e){return false;}
	};
	
	if(Ext.toolbar.Paging){
    	Ext.override(Ext.toolbar.Paging, {
	    	onPagingKeyDown : function(field, e){
	            var me = this,
	                k = e.getKey(),
	                pageData = me.getPageData(),
	                increment = e.shiftKey ? 10 : 1,
	                pageNum;
	
	            if (k == e.RETURN) {
	                e.stopEvent();
	                pageNum = me.readPageFromInput(pageData);
	                if (pageNum !== false) {
	                    pageNum = Math.min(Math.max(1, pageNum), pageData.pageCount);
	                    if(me.fireEvent('beforechange', me, pageNum) !== false){
	                        me.store.loadPage(pageNum);
	                    }
	                }
	            } else if (k == e.HOME || k == e.END) {
	                e.stopEvent();
	                pageNum = k == e.HOME ? 1 : pageData.pageCount;
	                field.setValue(pageNum);
	            } else if (k == e.UP || k == e.PAGEUP || k == e.DOWN || k == e.PAGEDOWN) {
	                e.stopEvent();
	                pageNum = me.readPageFromInput(pageData);
	                if (pageNum) {
	                    if (k == e.DOWN || k == e.PAGEDOWN) {
	                        increment *= -1;
	                    }
	                    pageNum += increment;
	                    if (pageNum >= 1 && pageNum <= pageData.pages) {
	                        field.setValue(pageNum);
	                    }
	                }
	            }
	        }
    	});
    }
	
	if(Ext.form.ComboBox){
    	Ext.override(Ext.form.ComboBox, {
    		beforeBlur: function(){
    			if(Ext.isEmpty(this.getRawValue()) || Ext.isEmpty(this.getValue())){
    				this.setValue(null);
    				try{this.fireEvent('select');}catch(e){}
    			}
    			try{this.store.clearFilter();}catch(e){} 
    			this.callOverridden();
			}
    	});
    }
});